﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DeviceInfoManage.BusinessLogicLayer;
public partial class SysMirrorRegister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["adminUserName"] == null)
            {
                Response.Redirect("login.aspx");
            }

        }
    }

    /*添加设备信息*/
    protected void Btn_Add_Click(object sender, EventArgs e)
    {
        /*建立一个记录对象，然后传入各个字段的属性值，最后调用插入函数执行添加*/
        reservedMan device = new reservedMan();
        device.deviceUser = this.DeviceName.Text;
        device.departmentName = this.DeviceDpt.SelectedValue;
        device.reservedTime = DateTime.Parse(this.txtWHSJ.Text);
        //device.errType = this.ddlErrType.SelectedValue;
        device.deviceModel = this.DeviceModel.Text;
        device.deviceSerialNumber = this.DeviceSerialNumber.Text;
        device.propertySerialNumber = this.deviceNumber.Text;
        device.reservedPersonId = int.Parse(this.ddlMaintPerson.SelectedValue);
        device.reservedPath = this.ddlErrType.Text;
        //device.errSolveWay = this.DeviceMemo.Text;
        /*插入函数返回添加是否成功，如果失败，ErrMessage中保存了错误信息*/
        if (device.Add(device) != -1)
            Response.Write("<script>alert('新备份信息添加成功!');</script>");//location.href='MaintRecordRegister.aspx';
        else
            Response.Write("<script>alert('添加失败!');</script>");

    }
}
